<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>导入邮箱数据 - Powered By liusany</title>

<script type="text/javascript" src="${ctx}/template/common/js/jquery.form.js"></script>



<script type="text/javascript">
$().ready(function() {

	$("#fileForm").submit(function() {
	});

	var isInitialized = false;
	var buildTime = 0;
	var count = 0;
	$("#fileForm").ajaxForm({
		
		beforeSubmit: function(data) {
			if (!isInitialized) {
				isInitialized = true;
				$("#submitButton").attr("disabled", true);
				$("#statusTr").show();
				$("#status").text("正在导入数据,请稍后...");
			}
		},
		success: function(data) {
		
		alert(data.message);
			count = data.count;
			buildTime += data.buildTime;
			if (data.status == "INSERT_FINISH") {
				$("#statusTr").hide();
				$("#submitButton").attr("disabled", false);
				
				var time;
				if (buildTime < 60000) {
					time = (buildTime / 1000).toFixed(2) + "秒";
				} else {
					time = (buildTime / 60000).toFixed(2) + "分";
				}
				$.dialog({type: "success", content: "导入邮箱数据"+ count +"条 耗时: " + time + "]", width: 380, modal: true, autoCloseTime: 3000});
				isInitialized = false;
				buildTime = 0;
			}
		}
	});

})
</script>

</head>
<body class="input">
	<div class="bar">
		导入邮箱数据
	</div>
	<div class="body">
		<form id="fileForm" action="${ctx}/admin/email/upload" enctype="multipart/form-data" method="post">
			<table class="inputTable">
				<tr>
					<th>
						导入邮箱文件: 
					</th>
					<td>
						<input type="file" name="file" />
						<label class="requireField">*</label>
					</td>
				</tr>
				<tr id="statusTr" class="hidden">
					<th>
						&nbsp;
					</th>
					<td>
						<span class="loadingBar">&nbsp;</span>
						<p id="status"></p>
					</td>
				</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" id="submitButton" class="formButton" value="确  定" hidefocus />&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus />
			</div>
		</form>
	</div>
</body>
</html>